<!--
 * @description:
 * @author: huangpeng
 * @date: 2023年08月24日 15:42
 * @Copyright:  2022-2023
!-->
<template>
  <div>
    <el-card class="link-link-container" shadow="always">
      <div class="link-title">
        <span>友情链接</span>
      </div>
      <div class="link-content">
        <div v-for="(link, index) in linkList" :key="index" class="link-card" @click="visitlink(link.linkUrl)">
          <div class="link-avatar">
            <img :key="link.linkIconUrl" :alt="link.linkName" :src="link.linkIconUrl">
          </div>
          <div class="link-info">
            <h3>{{ link.linkName }}</h3>
            <p>{{ link.remark }}</p>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script lang="ts">
import { Vue, Component } from "vue-property-decorator";
import { queryAllLink } from "@/api/blog/link";

@Component({})
export default class index extends Vue {

  /** 友情链接列表 */
  private linkList: any = [];

  private created() {
    this.queryLinkList();
  }

  /** 获取所有友情链接列表 */
  private queryLinkList() {
    queryAllLink().then((res: any) => {
      this.linkList = res.data;
    })
  }

  /** 跳转友情链接 */
  public visitlink(url: string) {
    window.open(url, '_blank')
  }
}
</script>
<style scoped lang="scss">
.link-link-container {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 5px;
  .link-title {
    font-weight: 600;
    font-size: 20px;
    color: #3B3E41;
  }
  .link-content {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    .link-card {
      border: 1px solid #e6ebf5;
      display: flex;
      align-items: center;
      cursor: pointer;
      transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
      position: relative;
      overflow: hidden;
      gap: 15px;
      padding: 0 5px;
      &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 4px;
        opacity: 0;
        transition: opacity 0.3s ease;
      }
      &:hover {
        transform: translateY(-5px) scale(1.02);
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        &::before {
          opacity: 1;
        }
        .link-avatar img {
          transform: scale(1.1) rotate(5deg);
        }
      }
      .link-avatar {
        position: relative;
        width: 60px;
        height: 60px;
        flex-shrink: 0;
        border-radius: 50%;
        padding: 3px;
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
          object-fit: cover;
          transition: transform 0.5s ease;
          border: 3px solid var(--card-bg);
        }
        .status {
          position: absolute;
          bottom: 5px;
          right: 5px;
          width: 12px;
          height: 12px;
          border-radius: 50%;
          background: #9ca3af;
          border: 2px solid var(--card-bg);
          box-shadow: 0 0 0 2px var(--card-bg);
          &.online {
            background: #10b981;
            animation: pulse 2s infinite;
          }
        }
      }
      .link-info {
        flex: 1;
        min-width: 0;
        h3 {
          color: var(--text-primary);
          font-size: 1.2em;
          font-weight: 600;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        p {
          color: var(--text-secondary);
          font-size: 0.95em;
          line-height: 1.5;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }
      }
    }
  }
}
</style>
